package com.taysear.parcel.util;

import java.util.Random;

/**
 * All the common logic of the application will came here.
 * 
 * @author Abdullahi
 *
 */
public class Util {
	
	
	/**
	 * Generates Key of a specified length
	 * 
	 * @param pNdigits
	 * @return String
	 */
	public static String generateKey(int pNdigits)
	{
		Random rand=new Random();
		int min=getLDV(pNdigits);
		int max=getLDV(pNdigits+1)-1;
		int randomNum = rand.nextInt((max - min) + 1) + min;

		return Integer.toString(randomNum);
	}
	
	/**
	 * Gets LowestValue in given digit range
	 * 
	 * @param n
	 * @return int
	 */
	public static int getLDV(int n)
	{
		String str="1";		
		for(int i=1; i<=(n-1);str+="0",i++);
		
		return Integer.parseInt(str);
	}
	
}
